<?php
/**
 + Created by:	Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webitsolution.com , info@webitsolution.com
			www.webitsolution.com, developer@webitsolution.com
 * Created on:	Oct 5, 2012
 ^
 + Project: 		WRecruit 
 * File Name:	module/topjsresume.php
 ^ 
 * Description: Module for WRecruit
 ^ 
 * History:		1.0.2 - Nov 27, 2012
 ^ 
 */

defined('_JEXEC') or die('Restricted access');

$noofresumes = $params->get('noofresumes', 7);
$title = $params->get('title', 1);
$nationality = $params->get('nationality', 1);
$gender = $params->get('gender', 1);
$available = $params->get('available', 1);

$category = $params->get('category', 1);
$jobtype = $params->get('jobtype', 1);
$salaryrange = $params->get('salaryrange', 1);
$highesteducation = $params->get('highesteducation', 1);
$experience = $params->get('experience', 1);
$posteddate = $params->get('posteddate', 1);
$theme = $params->get('theme', 1);
$separator = $params->get('separator', 1);
$colperrow = $params->get('colperrow',3);
//scs
$sliding= $params->get('sliding','1');
$consecutivesliding= $params->get('consecutivesliding','3');
$slidingdirection= $params->get('slidingdirection','1'); // 0 = left  , 1=up
//sce

$colwidth = Round(100/$colperrow,1);
$colwidth = $colwidth.'%';
$colcount = 1;



/** scs */
if($params->get('Itemid')) $itemid = $params->get('Itemid');			
else $itemid =  JRequest::getVar('Itemid');
$componentAdminPath = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_wrecruit';
$componentPath =  'components' . DS . 'com_wrecruit';
require_once $componentPath . DS . 'models' . DS . 'mpwrecruit.php';
$config = array( 'table_path' => $componentAdminPath . DS . 'tables');
$model = new WRecruitModelMpWRecruit($config);
$result = $model->getTopResumes($noofresumes,$theme);
$resumes = $result[0];
$trclass = $result[1];	
$dateformat = $result[2];	
/** sce */

$contents = '';
if ($resumes) { 
    $contents .= '<table cellpadding="0" cellspacing="0" border="0" width="100%" class="contentpane">';
	$isodd = 1;
	foreach ($resumes as $resume) {
	    $isodd = 1 - $isodd;
		$contents .= '<tr class="'.$trclass[$isodd].'">';  $contents .= '<td width="' .$colwidth. '">';
		$contents .= '<a href="index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=view_resume&vm=3&rd='. $resume->id .'&Itemid='.$itemid.'"><u><strong>'
	        . $resume->first_name.' '.$resume->last_name . '</strong></u></a></td>';
		if ($title == 1) {  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td width="'.$colwidth.'">';  $contents .= '<small>'.JText::_('JS_TITLE').': '.$resume->application_title.'</small></td>';	
		}if ($category == 1){  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td width="'.$colwidth.'">';  $contents .= '<small>'.JText::_('JS_CATEGORY').': '.$resume->cat_title.'</small></td>';	
		}if ($jobtype == 1) {  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td width="'.$colwidth.'">';  $contents .=  '<small>'.JText::_('JS_WORK_PREFERENCE').': '.$resume->jobtypetitle.'</small></td>';	
		}if ($highesteducation == 1) {  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td width="'.$colwidth.'">';  $contents .=  '<small>'.JText::_('JS_HIGHEST_EDUCATION').': '.$resume->educationtitle.'</small></td>';	
		}if ($salaryrange == 1)	{  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td width="'.$colwidth.'">'; $contents .=  '<small>'.JText::_('JS_SALARY').': '.$resume->symbol.$resume->rangestart.' - '.$resume->symbol.$resume->rangeend .'</small></td>';	
		}if ($experience == 1) {  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td width="'.$colwidth.'">';  $contents .=  '<small>'.JText::_('JS_EXPERIENCE').': '.$resume->total_experience.'</small></td>';	
		}if ($available == 1) {  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			 if ($resume->iamavailable == 1) $availabletext = JText::_('JS_YES'); 
			 else $availabletext = JText::_('JS_NO'); 
			$contents .=  '<td width="'.$colwidth.'">';  $contents .=  '<small>'.JText::_('JS_AVAILABLE').': '.$availabletext.'</small></td>';	
		}if ($gender == 1) {  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			 if ($resume->gender == 1) $gendertext=JText::_('JS_MALE');
			 else $gendertext=JText::_('JS_FEMALE'); 
			$contents .= '<td width="'.$colwidth.'">';  $contents .=  '<small>'.JText::_('JS_GENDER').': '.$gendertext.'</small></td>';	
		}if ($nationality == 1) {  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td width="'.$colwidth.'">';  if(isset($resume->nationality))$contents .=  '<small>'.JText::_('JS_NATIONALITY').': '.$resume->nationality.'</small></td>';	
		}if ($posteddate == 1) {  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td width="'.$colwidth.'">';  $contents .=  "<small>".JText::_('JS_POSTED').": ".date($dateformat,strtotime($resume->create_date))."</small></td>";
		}if ($separator == 1) {  if($colcount == $colperrow) { $contents .= '</tr><tr class="'.$trclass[$isodd].'">'; $colcount = 0; } $colcount++; 
			$contents .= '<td width="'.$colwidth.'">';  $contents .= '<hr style="border:dashed #C0C0C0; border-width:1px 0 0 0; height:0;line-height:0px;font-size:0;margin:0;padding:0;"></td>';
		}
		for($i = $colcount; $i < $colperrow; $i++){
			$contents .= '<td></td>';
		}
		$contents .= '</tr>';
		$colcount=1;
    }
	$contents .= '</table>';
			
			
	if ($sliding == 1) {
		//scs
		if($slidingdirection == 1 ){
			for ($a = 0; $a < $consecutivesliding; $a++){
				$contents .= $contents;
				}
			$contents =  '<marquee  direction="up" scrollamount="2" onmouseover="this.stop();" onmouseout="this.start()";>'.$contents.'</marquee>';
			$contents = $contents.'<br clear="all">';
		}else{
			
			$tcontents = '<table cellpadding="0" cellspacing="0" border="1" width="100%" class="contentpane"> <tr>';
			for ($a = 0; $a < $consecutivesliding; $a++){
				$scontents = '<td>'.$contents.'</td>';
			}
			$contents = $tcontents.$scontents.'</tr></table>';
			$contents =  '<marquee  scrollamount="2" onmouseover="this.stop();" onmouseout="this.start()";>'.$contents.'</marquee>';
		}
	//sce
	}

	echo $contents ;
}
?>

